package dao.Impl;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import dao.BookTypeDao;
import entity.BookInfo;
import entity.BookType;
import util.C3P0Util;

public class BookTypeDaoImpl implements BookTypeDao {

	@Override
	public List<BookType> getAllBookType() {
		List<BookType> list = null;
		
		//操作数据可对象
		QueryRunner qr = new QueryRunner(C3P0Util.getDataSource());
		
		//编写sql语句
		String sql = "select * from bookType";
		
		try {
			//BookInfo.class为核心
			list = qr.query(sql, new BeanListHandler<BookType>(BookType.class));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
		return list;
	}

}
